package com.kongxx.wicketstudy.tutorial.login;

import org.apache.wicket.Request;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebSession;

public final class LoginSession extends WebSession {
	private String user;

	public LoginSession(final WebApplication application, Request request) {
		super(application, request);
	}

	public final boolean authenticate(final String username,
			final String password) {
		if (user == null) {
			if ("admin".equalsIgnoreCase(username)
					&& "admin".equalsIgnoreCase(password)) {
				user = username;
			}
		}
		return user != null;
	}

	public boolean isSignedIn() {
		return user != null;
	}

	public String getUser() {
		return user;
	}

	public void setUser(final String user) {
		this.user = user;
	}
}